
String receivedString = "";
float temp = 0;
boolean isANumber = true;

void setup() {
  Serial.begin(9600);
}

void loop() {
  //Reads a line at a time from Serial, tries to parse it as a number
  
  // Read serial input:
  while (Serial.available() > 0) {
    
    byte raw = Serial.read();
    char inChar = (char)raw;

    if (inChar != '\n')
    {
     receivedString += inChar;
     if(!isDigit(inChar) & inChar != '.' && inChar != '\r')
     {isANumber = false;}
    }
    
    if (inChar == '\n')
    {
      int stringLength = receivedString.length();
      char myChars[stringLength];
      receivedString.toCharArray(myChars,stringLength);
      
      if(isANumber)
      {
         temp = atof( myChars);
      }
      Serial.println(receivedString);
      
      //reset values for the next line
      receivedString = "";
      isANumber = true;
      delay(50);
    }

      delay(10);
  }
}

